import type { CSSProperties } from "vue";

export default function useFullPlayerModal() {
  let playerModalShow = ref<boolean>(false);
  const headerStyle: CSSProperties = {
    padding: "10px",
    display: "none",
  };
  const bodyStyle: CSSProperties = {
    padding: "0px",
  };
  const openFullPlayerModal = (openFlag: boolean): void => {
    playerModalShow.value = openFlag;
  };
  const closeFullPlayerModal = (): void => {
    playerModalShow.value = false;
  };
  //歌曲名的获取
  const getSongName = (str: string): string => {
    let array = str.split("-");
    if (array.length) {
      return array[0];
    } else {
      return "未知";
    }
  };
  const getSingerName = (str: string): string => {
    let array = str.split("-");
    if (array.length > 1) {
      return array[1];
    } else {
      return "未知";
    }
  };
  const songPicUrl = (url: string | undefined): string => {
    return import.meta.env.VITE_APP_BASE_SERVER + url;
  };
  return {
    playerModalShow,
    headerStyle,
    bodyStyle,
    openFullPlayerModal,
    closeFullPlayerModal,
    songPicUrl,
    getSongName,
    getSingerName,
  };
}
